#ifndef AXIS_ALIGNED_BOUNDING_BOX_H_
#define AXIS_ALIGNED_BOUNDING_BOX_H_

#include "Renderable.h"

class AABBox : public Renderable
{
public:
    AABBox() :  m_x0(0.0f),m_y0(0.0f),m_z0(0.0f),
                m_x1(0.0f),m_y1(0.0f),m_z1(0.0f) {}
    AABBox(const Material& m, bool reflect, float reflectance) : Renderable(m,reflect, reflectance),
        m_x0(0.0f),m_y0(0.0f),m_z0(0.0f),
        m_x1(0.0f),m_y1(0.0f),m_z1(0.0f) {}
    AABBox(const Material& m, bool reflect, float reflectance,
        bool transparent, float opacity) : Renderable(m,reflect,reflectance,transparent,opacity),
        m_x0(0.0f),m_y0(0.0f),m_z0(0.0f),
        m_x1(0.0f),m_y1(0.0f),m_z1(0.0f) {}
    AABBox(float x0,float y0,float z0,float x1,float y1,float z1, 
           const Material& m, bool reflect,float reflectance) : Renderable(m,reflect, reflectance),
            m_x0(x0),m_y0(y0),m_z0(z0),
            m_x1(x1),m_y1(y1),m_z1(z1) {}
    AABBox(const Vec3& min, const Vec3& max,  
           const Material& m, bool reflect,float reflectance) : Renderable(m,reflect,reflectance),
            m_x0(min.m_x),m_y0(min.m_y),m_z0(min.m_z),
            m_x1(max.m_x),m_y1(max.m_y),m_z1(max.m_z) {}
    AABBox(const Vec3& min, const Vec3& max,  
        const Material& m, bool reflect,float reflectance,
        bool transparent, float opacity) : Renderable(m,reflect,reflectance,transparent,opacity),
        m_x0(min.m_x),m_y0(min.m_y),m_z0(min.m_z),
        m_x1(max.m_x),m_y1(max.m_y),m_z1(max.m_z) {}
    ~AABBox(){}
    void CreateFromPosAndHalf(const Vec3& pos, const Vec3& half)
    {
        m_x0 = pos.m_x - half.m_x;
        m_y0 = pos.m_y - half.m_y;
        m_z0 = pos.m_z - half.m_z;

        m_x1 = pos.m_x + half.m_x;
        m_y1 = pos.m_y + half.m_y;
        m_z1 = pos.m_z + half.m_z;
    }
    virtual void CalculateBox()
    {
        m_hasValidBox = true;
        m_box.SetValues(m_x0,m_y0,m_z0,m_x1,m_y1,m_z1);
#ifdef DEBUGGING
        m_information += "Class: AABBox";
#endif
    }
    virtual bool Hit(const Ray& ray, float& tmin, ContactData& data) const;
    Vec3 GetNormal( int face_in ) const;
private:
    float m_x0,m_y0,m_z0;
    float m_x1,m_y1,m_z1;
};

#endif